<?php
/**
 * Created by PhpStorm.
 * User: lee
 * Date: 2019-06-14
 * Time: 12:16
 */

ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';


use Doraemon\amqp\Queue;
use PhpAmqpLib\Message\AMQPMessage;


try {

    $channel = Queue::getChannel();

    $channel->exchange_declare(Queue::_EXCHANGE_NAME_, Queue::_EXCHANGE_TYPE_, false, true, false);

    $channel->queue_declare(Queue::QUEUE_BIZ, false, true, false, false);

    $channel->queue_bind(Queue::QUEUE_BIZ, Queue::_EXCHANGE_NAME_);

//需要对发出的消息进行到达确认
    $channel->tx_select();

    $msg = new AMQPMessage("test", array_merge([],
        ['delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT]
    ));

//发送消息
    $channel->basic_publish($msg, Queue::_EXCHANGE_NAME_);

    $channel->tx_commit();
}catch (\Exception $e){

    var_dump($e);
}



